package com.takeaway.dao.daolmpl;

import com.takeaway.dao.daointerface.UserDao;
import com.takeaway.pojo.Book;
import com.takeaway.pojo.User;
import com.takeaway.utils.JdbcUtils;
import java.util.ArrayList;
import java.util.List;

/**
 * @author 后台赖骏
 */
public class UserDaoImpl implements UserDao {
    @Override
    public int insert(User user) throws Exception{
        return JdbcUtils.insert(user);
    }

    @Override
    public int delete(Class<User> clz, String[] checkField, Object... factor) throws Exception{
        return JdbcUtils.delete(clz,checkField,factor);
    }

    @Override
    public int update(User user) throws Exception{
        return JdbcUtils.update(user);
    }

    @Override
    public User selectSingle(User user, String[] checkFields, Object... factor) throws Exception{
        return (User) JdbcUtils.selectSingle(user,checkFields,factor);
    }

    @Override
    public ArrayList<User> selectMore(Class<User> clz,int begin,int listNum) throws Exception{
        return (ArrayList<User>) JdbcUtils.selectMore(clz,begin,listNum);
    }

    @Override
    public ArrayList<User> selectMore(Class<User> clz, String[] checkField, Object... factor) throws Exception{
        return (ArrayList<User>) JdbcUtils.selectMore(clz,checkField,factor);
    }
    @Override
    public List<User> selectBookManage(int shopId) throws Exception {
        String sql = "SELECT user.* FROM book,food,`user` " +
                "WHERE foodId = food.id AND shopId = ?" +
                " AND userId = user.id";
        return JdbcUtils.executeSelectList(User.class, sql,shopId);
    }

}
